{
  "properties" : { },
  "id" : "9d3bacb4d9314003a80bd89c7b727b24",
  "script" : null,
  "groupId" : "b56a24453f064cf8bf33b13a4a2a6d91",
  "name" : "查询运行负载历史记录",
  "createTime" : 1727071152925,
  "updateTime" : 1726303552797,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "getHistory",
  "method" : "GET",
  "parameters" : [ {
    "name" : "deviceId",
    "value" : "D8279229554905540079",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "date",
    "value" : "2024-08-29",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }, {
    "name" : "type",
    "value" : "1",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": [\n        {\n            \"time\": \"00:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"00:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"00:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"00:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"01:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"01:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"01:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"01:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"02:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"02:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"02:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"02:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"03:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"03:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"03:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"03:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"04:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"04:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"04:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"04:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"05:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"05:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"05:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"05:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"06:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"06:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"06:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"06:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"07:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"07:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"07:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"07:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"08:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"08:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"08:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"08:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"09:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"09:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"09:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"09:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"10:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"10:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"10:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"10:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"11:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"11:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"11:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"11:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"12:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"12:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"12:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"12:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"13:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"13:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"13:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"13:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"14:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"14:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"14:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"14:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"15:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"15:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"15:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"15:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"16:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"16:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"16:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"16:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"17:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"17:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"17:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"17:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"18:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"18:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"18:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"18:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"19:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"19:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"19:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"19:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"20:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"20:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"20:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"20:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"21:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"21:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"21:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"21:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"22:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"22:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"22:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"22:45\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"23:00\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"23:15\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"23:30\",\n            \"value\": \"1\"\n        },\n        {\n            \"time\": \"23:45\",\n            \"value\": \"1\"\n        }\n    ]\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "root",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "ip",
      "value" : "10.61.167.3",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "deviceName",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import java.lang.reflect.Array
import java.time.format.DateTimeFormatter
import java.time.LocalTime
import java.time.LocalDate
import redis


boolean queryHis = true;
if (date.equals(LocalDate.now().toString())) {
    queryHis = false;
}
var vo
var alias

if (type == 1) {
    vo = db.table("ndmp_net_device_cpu").where().eq("device_id", deviceId).eq("gether_date", date).selectOne()
    alias = "cpuUsage"
} else if (type == 2) {
    vo = db.table("ndmp_net_device_memory").where().eq("device_id", deviceId).eq("gether_date", date).selectOne()
    alias = "memUsage"
} else if (type == 3) {
    vo = db.table("ndmp_net_device_delay_time").where().eq("device_id", deviceId).eq("gether_date", date).selectOne()
    alias = "delayTime"
} else {
    vo = db.table("ndmp_net_device_packet_loss").where().eq("device_id", deviceId).eq("gether_date", date).selectOne()
    alias = "packetLoss"
}


if (vo == null) {
    return new ArrayList()
}
var keySet = vo.keySet()

var res = new ArrayList()
for (key in keySet) {

    if (key.startsWith("time")) {
        Map map = new HashMap();
        String time = key.replace("time", "");
        String hour = time.substring(0, 2);
        String min = time.substring(2, 4);
        LocalTime mapKey = LocalTime.parse(hour + ":" + min);
        //查询今天之前的数据
        if (queryHis) {
            var value = vo.get(key)
            map.put("time", mapKey + "")
            map.put("value", value)
            res.add(map)
        } else {
            //查询当前时间 之前的数据
            if (mapKey.isBefore(LocalTime.now())) {
                var value = vo.get(key)
                map.put("time", mapKey + "")
                map.put("value", value)
                res.add(map)
            }
        }
    }
}


if (!queryHis) {
    var pointSoftVersion = redis.getPoint(vo.id, alias);

    var redisRes = "";
    if (null != pointSoftVersion) {
        redisRes = pointSoftVersion.value.get("0")
    }
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
    Map map = new HashMap();


    map.put("time", LocalTime.now().format(formatter))
    map.put("value", redisRes)

    res.add(map);
}
return res